package java8.stream.demo05matchstream;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @author ChangLiang
 * @date 2020/4/22
 */
public class AppTest {

    Stream<Integer> stream;

    @BeforeEach
    public void setUp() {
        stream =  Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7});
    }

    @Test
    @DisplayName("test stream allMatch")
    public void test(){
        boolean isMatch = stream.allMatch(i -> i > 10);
        System.out.println(isMatch);
    }

    @Test
    @DisplayName("test stream anyMatch")
    public void test2(){
        boolean isMatch = stream.anyMatch(i -> i > 6);
        System.out.println(isMatch);
    }

    @Test
    @DisplayName("test stream noneMatch")
    public void test3() {
        boolean isMatch = stream.noneMatch(i -> i < 0);
        System.out.println(isMatch);
    }
}
